package com.clayecloud.module_login.adapter;

import android.util.SparseArray;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

public class AdapterFragmentPager extends FragmentStateAdapter {

    private SparseArray<Fragment> fragments;
    private Fragment currentFragment;

    public AdapterFragmentPager(@NonNull FragmentActivity fragmentActivity, SparseArray<Fragment> fragments) {
        super(fragmentActivity);
        this.fragments = fragments;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        this.currentFragment = fragments.get(position);
        return currentFragment;
    }

    @Override
    public int getItemCount() {
        return fragments.size();
    }

    public Fragment getCurrentFragment(){
        return currentFragment;
    }


}
